<template>
  <div style="display: flex;flex-direction: column;background-color: #e9e9e9">
    <div class="hd">
      <span @click="$router.go(-1)"> 返回 </span>
      提现
    </div>
    <div>
      <div class="winfo">
        <div class="wline1">可提现金额</div>
        <div class="wline2">{{$store.state.agent.fxfee}}</div>
        <div class="wline3">不满1000元余额不能提现</div>
      </div>

      <div class="wform">
        <div class="wtitle">提现金额</div>
        <md-input-item
          v-model="pdata.fee"
          type="money"
          placeholder="输入要提现的金额"
        ></md-input-item>
         <div class="wtitle">我的银行卡</div>
        <md-input-item
          v-model="pdata.bankcard"
          type="bankCard"
          placeholder="银行卡号码 xxxx xxxx xxxx xxxx"
        ></md-input-item>

        <div class="wtitle">温馨提示</div>
        <div class="wtips"> 提现申请在5个工作日内审核完成 </div>
      </div>

      <div class="wbtn" @click="doTx"> 提现 </div>

    </div>

  </div>
</template>

<script>
import {Toast} from 'mand-mobile'
export default {
  name: 'withdaw',
  data () {
    return {
      pdata: {
        bankcard: '',
        fee: ''
      }
    }
  },
  created: async function () {

  },
  beforeMount: async function () {
    this.$store.commit('updateAgent')
  },
  mounted: async function () {
  },
  methods: {
    doTx: async function () {
      if (!this.pdata.bankcard) {
        Toast.info('请填写正确的银行卡'); return false
      }
      if (!this.pdata.fee) {
        Toast.info('请填写要提现的金额'); return false
      }
      let _postdata = {
        bankcard: this.pdata.bankcard,
        fee: this.pdata.fee,
        uid: this.$store.state.agent.uid ? this.$store.state.agent.uid : 43
      }
      let res = await this.$api.post('/fx/withdaw', _postdata)
      if (res.data.state) {
        Toast.succeed('提现成功')
      } else {
        Toast.failed('提现失败')
      }
    }
  }
}
</script>

<style scoped>
.wline1,.wline2,.wline3{
  text-align: center;
}
  .winfo{
    background-color: #fff;
    padding:20px;
  }
  .wline1{
    font-size: 14px;
    color: #777777;
  }
  .wline2{
    font-size: 22px;
    line-height: 1.5;
  }
  .wline3{
    font-size: 12px;
    color:rgb(96,189,206)
  }
  .wform{
    background-color: #fff;
    padding:20px;
    margin-top: 15px;
  }
  .wform .md-input-item-input {
    background-color: rgb(242,242,242);
  }
  .wtitle{
    font-size: 14px;
    line-height: 2;
  }
  .wtips{
    font-size: 12px;
  }
  .wbtn{
    width: 60vw;
    text-align: center;
    line-height: 40px;
    margin:20px auto;
    background-color: rgb(96,189,206);
    color:#fff
  }

</style>
